/**
 * create by young (young2f@outlook.com) on 2020/10/30
 */
'use strict';
window.wStore = {
  /**
   * 存储localStorage
   */
  setStore: (name, content) => {
    if (!name) return;
    if (typeof content !== 'string') {
      content = JSON.stringify(content);
    }
    window.localStorage.setItem(name, content);
  },
  /**
   * 获取localStorage
   */
  getStore: (name) => {
    if (!name) return;
    const content = window.localStorage.getItem(name);
    try {
     return  JSON.parse(content);
    } catch {
      return {}
    }
  },
  /**
   * 清除localStorage
   */
  clearStore: () => {
    window.localStorage.clear();
  },

  // getQueryStringByName: function(name) {
  //   let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
  //   let r = window.location.search.substr(1).match(reg);
  //   let context = '';
  //   if (r != null)
  //     context = r[2];
  //   reg = null;
  //   r = null;
  //   return context == null || context == '' || context == 'undefined' ? '' : context;
  // },

};
